package com.example.internetplus.utils.execlUtil;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
import com.example.internetplus.domain.po.HandStress;
import com.example.internetplus.utils.listeners.ReadExeclListener;
import org.springframework.stereotype.Component;

import java.io.InputStream;

@Component
public class ExeclUtil{
    public static <T>void readExeclByPath(String path,Class<T> clazz){
        ReadExeclListener readExeclListener = new ReadExeclListener<T>();
        //获取工作本
        ExcelReaderBuilder readWork = EasyExcel.read(path,clazz,readExeclListener);
        //获取工作表
        ExcelReaderSheetBuilder sheet = readWork.sheet();
        //读
        sheet.doRead();
    }

    public static <T>void readExeclByStream(InputStream uploadStream,Class<T> clazz){
        ReadExeclListener readExeclListener = new ReadExeclListener<HandStress>();
        ExcelReaderBuilder readWork = EasyExcel.read(uploadStream, clazz, readExeclListener);
        ExcelReaderSheetBuilder sheet = readWork.sheet();
        sheet.doRead();
    }
}
